package xkp.lesson.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import xkp.lesson.entity.Dept;
import xkp.lesson.entity.Emp;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;

@Controller
@RequestMapping("/hello")
public class HelloController {
    @GetMapping("/addEmp.action")
    public void addEmp(Integer empno, String ename, String job, Double sal, Dept dept, Date hiredate, String[] hobbies, HttpServletResponse response) throws IOException {
        System.out.println(empno);
        System.out.println(ename);
        System.out.println(job);
        System.out.println(sal);
        System.out.println(hiredate);
        Emp emp = new Emp();
        //emp.getEmpno();
        response.getWriter().write("success");
    }


    @PostMapping("/addEmp3.action")
    public void addEmp3(Emp emp, HttpServletResponse response) throws IOException {
        System.out.println(emp);
        response.getWriter().write("success");
    }

    @PostMapping("/addEmp4.action")
    public void addEmp4(@RequestBody Emp emp, HttpServletResponse response) throws IOException {
        System.out.println(emp);
        response.getWriter().write("success");
    }

    @ResponseBody
    @GetMapping("/getEmp.action")
    public Emp getEmp(){
        Emp emp = new Emp();
        emp.setEname("张三");
        emp.setEmpno(111);
        return emp;
    }


}